<?php
del_multi_property();
if(count($params)<4) {
    $rs_property = get_all_property_page();
}else {

    for($i=2;$i<count($params);$i++) {

        $arr = explode('~',$params[$i]);

        switch($arr[0]) {

            case "type": {
                    if($arr[1]==1) $condition .=" AND `type`='sell'"; else $condition = " AND `type`='rent'";
                    $type = intval($arr[1]);
                    break;
            }case




            "cat": {
                    $condition .=" AND `cat_id`=".intval($arr[1]);
                    $cat_id = intval($arr[1]);
                    break;
            }case




            "city": {
                    $str_pro_id = get_str_district_id(intval($arr[1]));
                    $geo_cond =" AND geo_id IN ".$str_pro_id;
                    $city_id = intval($arr[1]);
                    break;

            }case




            "dist": {
                    $geo_cond =" AND geo_id = ".intval(intval($arr[1]));
                    $dist_id = intval($arr[1]);
                    break;

            }case




            "search": {
                    $geo_cond =" AND title LIKE ".$db->quote('%'.$arr[1].'%');
                    $str_search = $arr[1];
                    break;

                }
        }
    }

    $rs_property = get_all_property_page("posted",$condition.$geo_cond);
}
?>
<script type="text/javascript" src="<?php echo SITE_JS_URL; ?>/inc_member.js"></script>
<script type="text/javascript" src="<?php echo SITE_JS_URL; ?>/inc_manage-property.js"></script>
<div class="container">
    <div class="content_mb">
<?php include_once 'inc/left.php';?>
        <div class="content_mb_r">
<?php include_once 'inc/post_property_top_center.php';?>
            <div style="margin-left: 20px;">
                <div class="title_mb_r31">
                    <div class="title_mb_r3_l">[Quản lý các thông tin đã đăng]</div>
                    <div class="mg_news">
                        <div class="mg_news_l"></div>
                        <div class="mg_news_bg">
                            <input type="text" name="keyword" id="keyword" value="<?=htmlentities_utf8($str_search)?>" /><a href="javascript:void(0);" onclick="isearch('<?=get_string_url_no_page()?>');">[Tìm kiếm]</a>
                        </div>
                        <div class="mg_news_r"></div>
                    </div>
                </div>

                <div class="top_mg"><span></span></div>
                <div class="bg_mg">

                    <div class="line_mg">
                        <ul>
                            <li>
                                <select name="loaihinh" id="loaihinh" onchange="changetype(this.value,'<?=get_string_url_no_page()?>');">
                                    <option value="">[Loại hình]</option>
                                    <option value="1" <?php setSelectedBoxValue(1,$type);?> >[Cần bán]</option>
                                    <option value="2" <?php setSelectedBoxValue(2,$type);?> >[Cho thuê]</option>
                                </select>
                            </li>
                            <li>
                                <select name="cat" onchange="changecat(this.value,'<?=get_string_url_no_page()?>');">
                                    <option value="">[Danh mục]</option>
                                    <?php

                                    $rs_cat = get_all_cat_by_type($type);
                                    if($rs_cat) {
                                        while($cat=$db->fetch_array($rs_cat)) {
                                            $selected = "";
                                            if($cat["cat_id"]==$cat_id) {
                                                $selected = 'selected="selected"';
                                            }
        echo "<option value='".$cat["cat_id"]."' ".$selected." >".$cat["cat_title"]."</option>";
    }
}
?> 
                                </select>
                            </li>
                            <li>
                                <select name="city" onchange="changecity(this.value,'<?=get_string_url_no_page()?>');">
                                    <option value="">[Tỉnh/TP]</option>
                                    <?php
                                    $rs_geo = get_all_geography();
                                    if($rs_geo) {
                                        while($geo=$db->fetch_array($rs_geo)) {
                                            echo "<option disabled='disabled' style='font-weight:bold;color:#4E80C1'>".$geo["geo_title"]."</option>";

                                            $rs_city = get_all_geography($geo["geo_id"]);
                                            while($geo_city=$db->fetch_array($rs_city)) {
                                                $selected = "";
                                                if($geo_city["geo_id"]==$city_id) {
                                                    $selected = 'selected="selected"';
                                                }
                                                echo "<option value='".intval($geo_city["geo_id"])."' ".$selected." >--".$geo_city["geo_title"]."</option>";
        }
    }
}
?>
                                </select>
                            </li>
                            <li>
                                <select name="district" onchange="changedist(this.value,'<?=get_string_url_no_page()?>');">
                                    <option value="">[Quận/Huyện]</option>
                                    <?php
                                    $rs_dist = get_all_geography($city_id);
                                    while($dist=$db->fetch_array($rs_dist)) {
                                        $selected = "";
                                        if($dist["geo_id"]==$dist_id) {
                                            $selected = 'selected="selected"';
    }
    echo "<option value='".intval($dist["geo_id"])."' ".$selected." >--".$dist["geo_title"]."</option>";
}
?>
                                </select>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="bt_mg"><span></span></div>

                <div class="bg_title_inbox">
                    <div class="bg_title_inbox_l">
                        <a href="javascript:void(0);" onclick="check_all();">[Chọn tất cả]</a>  |  <a href="javascript:void(0);" onclick="un_check_all();">[Bỏ chọn]</a>  |  <a href="javascript:void(0);" onclick="submit_form();">[Xóa]</a>
                    </div>
<?php
if($rs_property['total']>1) {
                                    ?>
                    <div class="bg_title_inbox_r">
                        <ul>
                            <li>
    <?php echo paging_small_member($rs_property['page'],$rs_property['total'],get_string_url_no_page());?>
                            </li>
                            <li>[Trang] <?php echo $rs_property['page'];?>/<?php echo $rs_property['total'];?></li>
                        </ul>
                    </div>
    <?php
}
?>
                </div>
                <form name="del_check" action="" method="post" id="form_del_check">
                    <div class="title_quanly">
                        <ul>
                            <li>
                                <div class="colum1"><input type="checkbox" class="checkAll" name="checkall" id="checkall" /></div>
                                <div class="colum2">[Tiêu đề] </div>
                                <div class="colum3">[Thông tin liên hệ]</div>

                            </li>
                        </ul>
                    </div>
                    <div class="list_quanly">
                        <ul>
                            <?php

                            while($rs=$db->fetch_array($rs_property['property'])) {

    $arr_contact=get_property_contact($rs["id"]);

    ?>
                            <li>
                                <div class="colum1"><input type="checkbox" name="check[]" id="check" class="check" value="<?php echo $rs['id'];?>" style="border:none;" /></div>
                                <div class="colum2">
                                    <ul>
                                        <li >
                                            <img src="<?php echo get_property_thumb($rs['thumb'],'91-71');?>" width="91px" height="71px" class="thumb_ql" />
                                            <a href="<?php echo get_link("property","detail",$rs['title_link']); ?>" target="_blank" title="<?=htmlentities_utf8($rs['title_link'])?>"><?php echo limitWord($rs['title'],100);?></a><br /><br />
    <?php
    $arrGeo = getGeoNameByGeoId($rs['geo_id']);
    ?>
                                            <b>[Vị trí]:</b> <?php echo $arrGeo['city'];?> l <?php echo $arrGeo['district'];?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <b>[Giá] :</b> <?php echo get_price_string($rs['price']);?> /m2<br />
                                            <b>[Diện tích]:</b> <?php echo showData($rs['area_build']);?> m2
                                        </li>
                                        <li class="bt_ql">
									[MS]: <?php if($rs['type']=='rent') echo 'R'.$rs['id']; else echo 'S'.$rs['id'];  ?>
                                            |  [Xem]: 18 [lượt]
                                            <a href="<?php echo get_link("property","detail",$rs['title_link']); ?>" target="_blank"><img src="<?php echo SITE_IMAGES_URL;?>/xemtin.gif" /></a>
                                            <a href="<?php echo get_link('member',$CONFIG_MEMBER_LINK['edit-posted-property']).'/'.$rs['id'];?>"><img src="<?php echo SITE_IMAGES_URL;?>/sua.gif" /></a>
                                        </li>
                                    </ul>
                                </div>
                                <div class="colum3" style="padding-top:10px">

                                    [Người đăng]: <b><?php echo showData($arr_contact["name"]);?></b><br/>
                                    Email: <b><?php echo showData($arr_contact["email"]);?></b><br/>
                                    [Điện thoại]: <b><?php echo showData($arr_contact["phone"]);?></b><br/>
                                    [Di động]: <b><?php echo showData($arr_contact["mobile"]);?></b>

                                </div>

                            </li>
    <?php
}
?>
                        </ul>
                    </div>
                </form>
                <div class="bg_title_inbox">
                    <div class="bg_title_inbox_l">
                        <a href="javascript:void(0);" onclick="check_all();">[Chọn tất cả]</a>  |  <a href="javascript:void(0);" onclick="un_check_all();">[Bỏ chọn]</a>  |  <a href="javascript:void(0);" onclick="submit_form();">[Xóa]</a>
                    </div>
                    <div class="bg_title_inbox_r2">
                        <div class="pagination2">
                            <?php
if(intval($rs_property["total"])>1 && !empty($params[1])) {
    echo paging_member($rs_property["page"],$rs_property["total"],get_string_url_no_page());
}
?>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>

</div>